<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="stylesheet" href="http://www.petercorke.com/RVC/common/toolboxhelp.css">
    <title>M-File Help: Animate</title>
  </head>
  <body>
  <table border="0" cellspacing="0" width="100%">
    <tr class="subheader">
      <td class="headertitle">M-File Help: Animate</td>
      <td class="subheader-left"><a href="matlab:open Animate">View code for Animate</a></td>
    </tr>
  </table>
<h1>Animate</h1><p><span class="helptopic">Create an animation</span></p><p>
Helper class for creating animations.  Creates a movie file or saves snapshots
of a figure as individual PNG format frames numbered 0000.png, 0001.png and so
on.

</p>
<h2>Example</h2>
<pre style="width: 90%%;" class="examples">
anim&nbsp;=&nbsp;Animate('movie.mp4');
</pre>
<pre style="width: 90%%;" class="examples">
for&nbsp;i=1:100
</pre>
<pre style="width: 90%%;" class="examples">
plot(...);
anim.add();
</pre>
<pre style="width: 90%%;" class="examples">
end
anim.close();
</pre>
<p>
will save the frames in an MP4 movie file using VideoWriter.

</p>
<h2>Alternatively</h2>
<pre style="width: 90%%;" class="examples">
anim&nbsp;=&nbsp;Animate('movie');
for&nbsp;i=1:100
</pre>
<pre style="width: 90%%;" class="examples">
plot(...);
anim.add();
</pre>
<pre style="width: 90%%;" class="examples">
end
anim.close();
</pre>
<p>
To convert the image files to a movie you could use a tool like ffmpeg

</p>
<pre style="width: 90%%;" class="examples">
ffmpeg&nbsp;-r&nbsp;10&nbsp;-i&nbsp;movie/%04d.png&nbsp;out.mp4
</pre>
<hr>
<a name="Animate"><h1>Animate.Animate</h1></a>
<p><span class="helptopic">Create an animation class</span></p><p>
<strong>a</strong> = <span style="color:red">ANIMATE</span>(<strong>name</strong>, <strong>options</strong>) initializes an animation, and creates
a movie file or a folder holding individual frames.

</p>
<p>
<strong>a</strong> = <span style="color:red">ANIMATE</span>({<strong>name</strong>, <strong>options</strong>}) as above but arguments are passed as a cell array,
which allows a single argument to a higher-level option like 'movie',M to express
options as well as filename.

</p>
<h2>Options</h2>
<table class="list">
  <tr><td style="white-space: nowrap;" class="col1">'resolution', R</td> <td>Set the resolution of the saved image to R pixels per inch.</td></tr>
  <tr><td style="white-space: nowrap;" class="col1">'profile', P</td> <td>Create an MP4 file directly, see VideoWriter</td></tr>
  <tr><td style="white-space: nowrap;" class="col1">'fps', F</td> <td>Frame rate (default 30)</td></tr>
</table>
<h2>Notes</h2>
<ul>
  <li>if a profile is given a movie is created, see VideoWriter for allowable
profiles.</li>
  <li>if the file has an extension a movie is created.</li>
  <li>otherwise a folder full of frames is created.</li>
</ul>
<h2>See also</h2>
<p>
<a href="VideoWriter.html">VideoWriter</a></p>
<hr>
<a name="add"><h1>Animate.add</h1></a>
<p><span class="helptopic">Adds current plot to the animation</span></p><p>
A.<span style="color:red">ADD</span>() adds the current figure in PNG format to the animation
folder with a unique sequential filename.

</p>
<p>
A.<span style="color:red">ADD</span>(<strong>fig</strong>) as above but captures the figure <strong>fig</strong>.

</p>
<h2>See also</h2>
<p>
<a href="print.html">print</a></p>
<hr>
<a name="close"><h1>Animate.close</h1></a>
<p><span class="helptopic">Closes the animation</span></p><p>
A.<span style="color:red">CLOSE</span>() closes the video file.

</p>
<hr>

<table border="0" width="100%" cellpadding="0" cellspacing="0">
  <tr class="subheader" valign="top"><td>&nbsp;</td></tr></table>
<p class="copy">&copy; 1990-2014 Peter Corke.</p>
</body></html>